<?php
/**
 * Created by PhpStorm.
 * User: LiuJiaJun
 * Date: 2019/1/22
 * Time: 14:22
 */

namespace api\storage\model;


use think\Model;

class ClientModel extends Model
{
    protected $table = 'iwh_client';
    protected $pk = 'pk';

    /**
     * 根据仓库uuid字段查询数据
     *
     * @param $uuid
     * @return false|\PDOStatement|string|\think\Collection
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    public function queryByStorageUuid($uuid){
        $where['storage_uuid'] = $uuid;
        $where['status'] = 1;
        return $this->where($where)->select();
    }

    /**
     * 查询uid的信息
     *
     * @param $uuid
     * @return array
     */
    public function queryUid($uuid){
        $where['storage_uuid'] = $uuid;
        $where['status'] = 1;
        return $this->where($where)->column('uid');
    }

    /**
     * 根据code获取uid
     *
     * @param $code
     * @return mixed
     */
    public function queryUidByCode($code){
        return $this->where('code',$code)->where('status',1)->value('uid');
    }
}